<template>
  <div>
    <!--面包屑 !-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片试图 -->
    <el-card>
      <el-table
        :data="RightsList"
        border
        stripe
      >
        <el-table-column
          type="index"
          label="#"
        ></el-table-column>
        <el-table-column
          prop="authName"
          label="权限名字"
        >
        </el-table-column>
        <el-table-column
          prop="path"
          label="路径"
        >
        </el-table-column>
        <el-table-column
          prop="path"
          label="权限等级"
        >
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level==0">一级权限</el-tag>
            <el-tag
              v-else-if="scope.row.level==1"
              type="success"
            >二级权限</el-tag>
            <el-tag
              v-else-if="scope.row.level==2"
              type="warning"
            >一级权限</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  props: {},
  data() {
    return {
      // 权限列表
      RightsList: [],
      RightsType: 'list',
    }
  },
  computed: {},
  created() {
    this.GetRightsList()
  },
  mounted() {},
  watch: {},
  methods: {
    // 连接数据库
    async GetRightsList() {
      const { data: res } = await this.$http.get('rights/' + this.RightsType)
      if (res.data.status !== 200) {
        this.$message.error('获取权限列表失败')
      }
      this.$message.success('获取权限列表成功')
      console.log(res)
      this.RightsList = res.data
    },
  },
  components: {},
}
</script>

<style scoped lang="less">
</style>
